<template>
  <div class="todo-item" :class="{ completed: completed }">
    <input type="checkbox" :checked="completed" @change="toggleCompletion" />
    <span>{{ title }}</span>
    <button @click="removeTodo">删除</button>
  </div>
</template>

<script>
export default {
  props: {
    title: {
      type: String,
      required: true
    },
    completed: {
      type: Boolean,
      required: true
    }
  },
  methods: {
    toggleCompletion() {
      this.$emit('update:completed', !this.completed);
    },
    removeTodo() {
      this.$emit('remove-todo');
    }
  }
};
</script>

<style scoped>
.todo-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px;
  margin: 5px 0;
  border: 1px solid #eee;
}

.completed {
  text-decoration: line-through;
  color: #888;
}

button {
  background-color: #ff4444;
  color: white;
  border: none;
  padding: 5px 10px;
  border-radius: 3px;
  cursor: pointer;
}
</style>